package com.itheima;

/**
 * @auther Macrydy
 * @date 2020/7/9 15:31
 */
public class VolatileDemo {
    public static void main(String[] args) {
        Thread thread1 = new Thread(new Boy());
        Thread thread2 = new Thread(new Girl());
        thread1.start();
        thread2.start();
    }
}
class Boy implements Runnable{

    @Override
    public void run() {


        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Money.money=900;
        System.out.println("偷偷花了100");
    }
}
class Girl implements Runnable{

    @Override
    public void run() {
        while(Money.money!=1000){
        }
        System.out.println("谁花了我的钱！！！");
    }
}
class Money {
    public static volatile int money=1000;

}